//
//  SISSComplainSuggestionViewController.m
//  SISSAPP
//
//  Created by 优房网 on 2017/5/4.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSComplainSuggestionViewController.h"
#import "SISSTextView.h"
#import "SISSComplainCollectionViewCell.h"
#import "SISSUploadImageView.h"
#import "SISSNetworkingManager+Complain.h"
#import "SISSNetworkingManager+Comment.h"

@interface SISSComplainSuggestionViewController ()
@property (weak, nonatomic) IBOutlet SISSTextView *complainSuggestionTextView;
@property (weak, nonatomic) IBOutlet SISSUploadImageView *uploadImageView;



@end

@implementation SISSComplainSuggestionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
}

- (void)setupSubviews {
    [super setupSubviews];
    
    self.complainSuggestionTextView.font = [UIFont systemFontOfSize:15.f];
    
    self.uploadImageView.isHiddenTitle = YES;
}



/**
 确定按钮点击事件
 */
- (IBAction)confirmButtonClickAction:(id)sender {
    
    NSString *content = self.complainSuggestionTextView.text;
    if (content.length == 0) {
        [self alertActionAlertWithTitle:@"提示" message:@"请填写投诉建议内容"];
        return;
    }
    [kNetworkNoUTF8Manager insertComplainAndSuggestionWithAcrId:@"-1" complainType:1 commentType:-1 content:content images:self.uploadImageView.images success:^(id responseObject) {
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            [[NSOperationQueue mainQueue] addOperationWithBlock:^{
                [SISSTools showSVErrorTitle:responseObject[@"message"] andTime:1 andColor:YES];
            }];
            return ;
        }
        
        if ([responseObject[@"code"] integerValue] == 200) {
            [SISSTools showSVSuccessTitle:@"提交成功" andTime:1 andColor:YES];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [self.navigationController popViewControllerAnimated:YES];
            });
        }
        
    } failed:^(NSError *error) {
        
        NSLog(@"%@",error);
    }];
}



@end
